#pragma once
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QTimer>
#include <QFutureWatcher>
#include <functional>
#include <QEventLoop>
#include <QByteArray>

class CHttpManager : public QObject
{
	Q_OBJECT

	QNetworkAccessManager m_manager;
	static CHttpManager* ms_httpManager;
	CHttpManager() = default;
	
public:
	static CHttpManager* getInstance()
	{
		if (!ms_httpManager)
		{
			ms_httpManager = new CHttpManager;
		}
		return ms_httpManager;
	}
	CHttpManager(const CHttpManager&) = delete;
	CHttpManager& operator=(const CHttpManager&) = delete;


	void AsyncGet(const QString& url, const std::function<void(QString, bool)>& fun);

	void AsyncGetByteData(const QString& url, const std::function<void(QByteArray, bool)>& fun);
};
